﻿using BLL;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BankSysDemo.WebUI
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string zh = TextBox1.Text;
            string mm = TextBox2.Text;
            string yzm = TextBox3.Text;
            if (Session["vcode"] != null && yzm != Session["vcode"].ToString())
            {
                Response.Write("<script>alert('验证码错误，请重新输入！')</script>");
                return;
            }
            UserModel user = UserManage.DoLogin(zh, mm);
            if (user == null)
            {
                //账号或密码错误
                Response.Write("<script>alert('账号或密码错误，请重新输入！')</script>");
            }
            else
            {
                //登录成功
                Session["user"] = user;
                Response.Redirect("Home.aspx");
            }
        }
    }
}